<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title><spring:message code="message.list.ShangPinMuLuChaKan"/></title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>药品列表</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">药品列表</a></li>
        </ol>
    </section>
     <section class ="content">
        <form id="form" method="post" class="form-horizontal">    
         <div class=" box box-success">
            <div class="box-body">
               <div class="input">
                    <div class="textalign1"><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugName" name="drugName" placeholder="<spring:message code="message.listForm.tongYongMing"/>/<spring:message code="message.listForm.pinYinMa"/>" />
                    </div>
                    
                    <div class="textalign"><spring:message code="message.listForm.XiangMuMingCheng"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="projName" name="projName" placeholder="<spring:message code="message.listForm.XiangMuMingCheng"/>" />
                    </div>
                    <div class="boxinput">
                       <button type="button" onclick="gridSerch()" class="btn btn-success btn-sm" id="selectDicCompType"><spring:message code="message.button.seachSpacing"/></button>
                    </div>
               </div>
           </div>
           </div>
        </form> 
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
  //绑定回车
    $('#drugName,#projName').bind('keydown', function(event) {
        if (event.keyCode == "13") {
            $('#selectDicCompType').click();
        }
    });	
    $("#drugName").focus();//加载页面光标在第一个查询框内
    
    
    
    var searchType = 0;
    
    function moreSerch(obj) {
        if (searchType == 0) {
            searchType = 1;
            $("div.moreSerch").slideDown();
            $(obj).html("<spring:message code="message.button.JianDanChaXun"/>");
        } else {
            searchType = 0;
            $("div.moreSerch").slideUp();
            $(obj).html("<spring:message code="message.button.GaoJiChaXun"/>");
            $("#goodsCode,#drugCode,#catCompName,#isLowprice,#isSmallprice,#isSmallsource").val("");
        }
    }
    
	function gridSerch(page) {
		var drugName = $.trim($("#drugName").val());
        var projName = $.trim($("#projName").val());
        var compName = $.trim($("#compName").val());
        var goodsCode = $.trim($("#goodsCode").val());
        var drugCode = $.trim($("#drugCode").val());
        var catCompName = $.trim($("#catCompName").val());
        var isLowprice = $.trim($("#isLowprice").val());
        var isSmallprice = $.trim($("#isSmallprice").val());
        var isSmallsource = $.trim($("#isSmallsource").val());
        var goodsSource = $.trim($("#goodsSource").val());
        var status = $.trim($("#status").val());

        $("#gridlist").jqGrid('setGridParam', {  
            datatype:'json',
            postData:{
                "drugName":drugName,
                "projName":projName,
                "compName":compName,
                "goodsCode":goodsCode,
                "drugCode":drugCode,
                "catCompName":catCompName,
                "isLowprice":isLowprice,
                "isSmallprice":isSmallprice,
                "isSmallsource":isSmallsource,
                "goodsSource":goodsSource,
                "status":status
            },
            page : 1
        }).trigger("reloadGrid"); //重新载入  
	}
	
        $(function () {
            $("#gridlist").jqGrid({
                url: "getBaseGoodsListJsonByComp.html",
                mtype: "POST",
                postData: { "projId" : "${bidProject.projId}"},
                datatype: "json",
                autowidth: true,
                colNames:[
                          '<spring:message code="message.listForm.shangBianMa"/>',
                          '<spring:message code="message.listForm.ZhongBiaoJia"/>',
                          '<spring:message code="message.listForm.ZhongBiaoHouLingShouJia"/>',
		   	       	  	  '<spring:message code="message.listForm.yaoPinBianMa"/>',
                          '<spring:message code="message.listForm.tongYongMing"/>', 
                          '<spring:message code="message.listForm.jiXing"/>',
                          '<spring:message code="message.listForm.guiGe"/>',
                          '<spring:message code="message.listForm.zhuanHuanXiShu"/>',
                          '<spring:message code="message.listForm.baoZhuangDanWei"/>', 
                          '<spring:message code="message.listForm.caiZhi"/>',
                          '<spring:message code="message.listForm.ZhongBiaoQiYe"/>',
                          '<spring:message code="国药准字"/>',
    		   	          '<spring:message code="message.listForm.XiangMuMingCheng"/>',
 		   	              '<spring:message code="message.listForm.yaoPinLaiYuan"/>',
 		   	      		  '<spring:message code="message.listForm.BeiAnLeiXing"/>',
	   	                  '<spring:message code="message.listForm.ShangPinFenLei"/>',
	   	       			  '<spring:message code="message.listForm.shiFouDiJiaYao"/>',
	   	         		  '<spring:message code="message.listForm.shiFouLianJiaYao"/>',
	   	         		  '<spring:message code="message.listForm.shiFouGongYinJinZhangYao"/>'
                          ],
                colModel:[
                    {name:'goodsCode',hidden:true,index:'goodsCode',sortable:false, width:100,align:"center", sorttype:false},
                    {name:'proPriceLimit',index:'proPriceLimit',sortable:false, width:70, align:"right",sorttype:false,
                        formatter:function(cellvalue, options, row){ 
                        return formatAmount(cellvalue, options, row);
                        }},
	                {name:'retailPriceLimit',index:'retailPriceLimit',sortable:false, width:90, align:"right",sorttype:false,
	                    formatter:function(cellvalue, options, row) {
	                        var f_x = Math.round(cellvalue * 100) / 100;
	                        var s_x = f_x.toString();
	                        var pos_decimal = s_x.indexOf('.');
	                        
	                        if (pos_decimal < 0) {
	                            pos_decimal = s_x.length;
	                            s_x += '.';
	                        }
	                        
	                        while (s_x.length <= pos_decimal + 2) {
	                            s_x += '0';
	                        }
	                        return s_x;
	                    }
	                },
                    {name:'drugCode',index:'drugCode',sortable:false, width:100,hidden:true, align:"center",sorttype:false/*,
                        formatter:function(val, opts, row) {
                         return "<a href=\"javascript:showDrugInfo('"+val+"');\">"+val+"</a>"
                        }*/
                    },
                    {name:'qualityspecName',index:'drugName',sortable:false, width:140,align:"left", sorttype:false},
                    {name:'formName',index:'formName', width:80,sortable:false, align:"center"},
                    {name:'specName',index:'specName', width:80, sortable:false,align:"left",sorttype:false},
                    {name:'factor',index:'factor', width:80, sortable:false,align:"center",sorttype:false},
                    {name:'unitName',index:'unit', width:40,sortable:false, align:"center",sorttype:false},
                    {name:'materialName',index:'materialName',sortable:false, width:80, align:"left",sorttype:false,hidden:true},
                    {name:'catCompName',index:'compName',sortable:false, hidden:true, width:180, align:"left",sorttype:false/*,
                        formatter:function(val, opts,row) {
                            return "<a href='javascript:showCompInfo(\"" + row.catCompCode + "\", \"" + val + "\");'>"+val+"</a>"
                        }*/
                   },
                    
                   
                   
                   
                   
                    {name:'drugMedicine',index:'drugMedicine',sortable:false, width:200, align:"left",sorttype:false},
                    {name:'projName',index:'projectName',sortable:false, width:200, align:"left",sorttype:false},
                    {name:'goodsSource',index:'bakDrugFlagText',sortable:false, width:80, align:"center",sorttype:false,hidden:true,
                        formatter : function(val, opts, rowdata) {
                            var str = "";
                            if (val == 1) {
    		   					str = "<spring:message code="message.listForm.ZhaoBiaoCaiGou"/>";
    		   				} else if (val == 2) {
    		   					str = "<spring:message code="message.listForm.DingDianShengChan"/>";
    		   				} else if (val == 3) {
                                str = "<spring:message code="message.listForm.GuaWwangCaiGou"/>";
                            } else if (val == 4) {
                                str = "<spring:message code="message.listForm.YiJiaCaiGou"/>";
                            } else if (val == 5) {
                                str = "<spring:message code="message.listForm.BeiAnCaiGou"/>";
                           
                            }
                            return str;
                        }   
                    },
                    {name:'isLongtimePlan',index:'isLongTimePlanText', sortable:false,width:80, align:"center",sorttype:false,hidden:true,
                        formatter : function(val, opts, rowdata) {
                            var str = "";
                            if (val == 0) {
                                str = "<spring:message code="message.listForm.LinShiBeiAn"/>";
                            } else if (val == 1) {
                                str = "<spring:message code="message.listForm.ChangQiBeiAnLeiXing"/>";
                            }
                            return str;
                        }
                    },
                    {name:'drugCat',index:'drugCatText', hidden:true,sortable:false, width:100, align:"center",sorttype:false,
                        formatter : function(val, opts, rowdata) {
                            var str = "";
                            if (val == 1) {
                                str = "<spring:message code="message.listForm.HuaXueJiShengWuZhiYao"/>";
                            } else if (val == 2) {
                                str = "<spring:message code="message.listForm.ZhongChengYao"/>";
                            } else if (val == 3) {
                                str = "<spring:message code="message.listForm.ZhongYaoYingPian"/>";
                            }
                            return str;
                        }
                    },
                    {name:'isLowprice', width:80, align:"center",sortable:false,sorttype:false,hidden:true,
                        formatter : function(val, opts, rowdata) {
                            var str = "";
                            if (val == 0) { 
                                str = "<spring:message code="message.listForm.fou"/>";
                            } else if (val == 1) {
                                str = "<spring:message code="message.listForm.shi"/>";
                            } else if (val == 9) {
                                str = "<spring:message code="message.listForm.WeiZhi"/>";
                            }
                            return str;
                        }
                    },
                    {name:'isSmallprice', width:80, sortable:false,align:"center",sorttype:false,hidden:true,
                        formatter : function(val, opts, rowdata) {
                            var str = "";
                            if (val == 0) { 
                                str = "<spring:message code="message.listForm.fou"/>";
                            } else if (val == 1) {
                                str = "<spring:message code="message.listForm.shi"/>";
                            } else if (val == 9) {
                                str = "<spring:message code="message.listForm.WeiZhi"/>";
                            }
                            return str;
                        }
                    },
                    {name:'isSmallsource', width:80, sortable:false,align:"center",sorttype:false,hidden:true,
                        formatter : function(val, opts, rowdata) {
                            var str = "";
                            if (val == 0) { 
                                str = "<spring:message code="message.listForm.fou"/>";
                            } else if (val == 1) {
                                str = "<spring:message code="message.listForm.shi"/>";
                            } else if (val == 9) {
                                str = "<spring:message code="message.listForm.WeiZhi"/>";
                            }
                            return str;
                        }
                    }
                ],
                rowNum: 20,
                rowList: [10, 20,50,100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
                caption: "药品列表",
                jsonReader: {
                    repeatitems: false,
                    id: "drugId"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $("#gridlist").jqGrid("setGridHeight", create());
            $(window).trigger("resize");
        });
    </script>
</body>
</html>